package com.tangmin.service.impl;/**
 * @ClassName UserServiceImpl
 * @Description TODO
 * @date 2021/9/17 21:20
 * @Version 1.0
 */

import com.tangmin.dao.UserDao;
import com.tangmin.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * UserService的实现类
 *
 * @author YourName
 * @date 2021-09-17 21:20
 **/
public class UserServiceImpl implements UserService {
    private UserDao userDao;
////    通过set方法将 userDao 对象注入 service
//    public void setUserDao(UserDao userDao) {
//        this.userDao = userDao;
//    }

    //通过构造方法将userDao对象注入service
    public UserServiceImpl(UserDao userDao) {
        this.userDao = userDao;
    }

    public UserServiceImpl() {
    }

    @Override
    public void save() {
//        ApplicationContext app = new ClassPathXmlApplicationContext("applicationContext.xml");
//        UserDao userDao = (UserDao)app.getBean("userDao");
        userDao.save();
    }
}
